package com.leemz.design.chapter5.none;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class AppConfig {
    private String parameterA;
    private String parameterB;

    public String getParameterA() {
        return parameterA;
    }

    public String getParameterB() {
        return parameterB;
    }

    public AppConfig() {
        readConfig();
    }

    private void readConfig() {
        Properties properties = new Properties();
        InputStream is = null;
        try {
            is = AppConfig.class.getClassLoader().getResourceAsStream("app_config.properties");
            properties.load(is);
            this.parameterA = properties.getProperty("paramA");
            this.parameterB = properties.getProperty("paramB");
        } catch (Exception e) {
            System.out.println("加载匹配文件错误:");
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
